//
//  YZSportSportingViewController.m
//  runrun
//
//  Created by yongzhen on 16/10/21.
//  Copyright © 2016年 yongzhen. All rights reserved.
//

#import "YZSportSportingViewController.h"
#import <MAMapKit/MAMapKit.h>
#import "YZSportMapViewController.h"
#import "YZCircleAnimator.h"
@interface YZSportSportingViewController ()
@property (nonatomic,strong)YZSportMapViewController * mapViewController;
@property (weak, nonatomic) IBOutlet UIButton *button;
@end

@implementation YZSportSportingViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupMapViewConteooler];
    
 
    

}


-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    CGFloat compassX = _button.center.x - _mapViewController.mapView.compassSize.width * 0.5;
     CGFloat compassY = _button.center.y - _mapViewController.mapView.compassSize.height * 0.5;
    
    
    _mapViewController.mapView.compassOrigin = CGPointMake(compassX, compassY);
    
}

- (IBAction)statusChange:(UIButton *)sender {
    
    _mapViewController.sportTracking.sportStatus = sender.tag;
    
    
}

- (IBAction)showMapViewController:(UIButton *)sender {
  
    
    
    [self presentViewController:_mapViewController animated:YES completion:nil];
    
}



-(void)setupMapViewConteooler{
    
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"YZSportSporting" bundle:nil];
    _mapViewController = [sb instantiateViewControllerWithIdentifier:@"stoprboardID"];
     
    
    
    for (UIViewController *childVC in self.childViewControllers) {
        if ([childVC isKindOfClass:[YZSportMapViewController class]]) {
            _mapViewController = (YZSportMapViewController *)childVC;
            break;
        }
    }
    
    _mapViewController.sportTracking = [[YZSportTracking alloc] initWithType:_sportType sportStatus:YZSportStatusContinue];
    
    
    
//    YZSportMapViewController *vc = [YZSportMapViewController new];
//    [self addChildViewController:vc];
//    [self.view addSubview:vc.view];
//
//    
//    vc.sportTracking = [[YZSportTracking alloc] initWithType:_sportType];
//    vc.view.frame = self.view.bounds;
//    [vc didMoveToParentViewController:self];
    
    
    
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




@end
